package gwt.bbsbot.server.entity;

import gwt.bbsbot.server.twitter.TwitterManager;

import java.util.Calendar;
import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class AnswerDataEntity {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;
	@Persistent
	private String name;
	@Persistent
	private Long questionId;
	@Persistent
	private String answerData;
	@Persistent
	private Date day;
	@Persistent
	private String profileImageURL;
	@Persistent
	private String genre;
	

	public AnswerDataEntity(String name, Long questionId, String answerData,
			String profileImageURL, String genre) {
		this.name = name;
		this.questionId = questionId;
		this.answerData = answerData;
		this.day = Calendar.getInstance().getTime();
		this.genre = genre;
		
		if (profileImageURL == null) {
			TwitterManager tm = new TwitterManager();
			this.profileImageURL = tm.getProfileImageURL(name);
		} else {
			this.profileImageURL = profileImageURL;
		}
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getDay() {
		return day;
	}

	public void setDay(Date day) {
		this.day = day;
	}

	@Override
	public String toString() {
		return "name: " + this.name + " text:" + this.answerData;
	}

	public String getProfileImageURL() {
		return profileImageURL;
	}

	public String getGenre() {
		return genre;
	}

	public void setProfileImageURL(String profileImageURL) {
		this.profileImageURL = profileImageURL;
	}

	public void setGenre(String genre) {
		this.genre = genre;
	}

	public Long getQuestionId() {
		return questionId;
	}

	public void setQuestionId(Long questionId) {
		this.questionId = questionId;
	}

	public String getAnswerData() {
		return answerData;
	}

	public void setAnswerData(String answerData) {
		this.answerData = answerData;
	}

	
	
}
